<%@ include file="/WEB-INF/jsp/include/taglib.jsp" %>

<h1>
    <fmt:message key="app.forum.topic.list"/>
</h1>

<authz:authorize ifAnyGranted="ROLE_SUPERVISOR">
    <a href="<c:url value="/system/addtopic.form"/>">
        <fmt:message key="app.forum.topic.add"/>
    </a>
</authz:authorize>

<c:forEach items="${entries}" var="entry">
    <div class="entry">
        <div class="entry-left">
            <img src="/static-images/pic-forum.gif">
        </div>
        <div class="entry-right">
            <div class="entry-header">
                <a href="<c:url value="/topic.form/${entry.id}"/>" id="topic_${entry.id}">
                    <c:out value="${entry.header}"/>
                </a>
            </div>
            <div class="entry-data" style="text-align: right;">
                <authz:authorize ifAnyGranted="ROLE_SUPERVISOR">
                    <a href="<c:url value="/system/edittopic.form/${entry.id}"/>">
                        <fmt:message key="app.forum.topic.edit"/>
                    </a>
                </authz:authorize>
            </div>
            <div class="entry-text">
                <c:out value="${entry:preview(entry.text)}" escapeXml="false"/>
                <c:if test="${entry:isShortened(entry.text)}">
                    <a href="<c:url value="/post.form/${entry.id}"/>"><fmt:message key="app.entry.readEntire"/></a>
                </c:if>
            </div>
        </div>
    </div>
    <br/>
</c:forEach>
